package com.first.course.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.first.common.pojo.EduSubject;
import com.first.common.vo.Result;
import com.first.course.service.EduSubjectService;
import com.first.course.vo.EduSubjectVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @program: first-project
 * @description:
 * @author: 路志欣
 * @create: 2023-05-27 16:15
 **/
@RestController
@RequestMapping("/cours/subject")
public class EduSubjectController {
    @Autowired
    private EduSubjectService eduSubjectService;


    @ApiOperation(value = "分页模糊查询")
    @PostMapping("/findsubject/{pageCurrent}/{pagesize}")
    private Result findSubject(@PathVariable Integer pageCurrent, @PathVariable Integer pagesize, @RequestBody EduSubjectVo eduSubjectVo){
        Page<EduSubject> subject = eduSubjectService.findSubject(pageCurrent, pagesize, eduSubjectVo);
        return Result.success(subject);
    }

    @ApiOperation(value = "修改状态")
    @PostMapping("/changeStatusId/{id}/{statusId}/{parentId}")
    private Result ChangeStatusId(@PathVariable String id,@PathVariable String statusId,@PathVariable String parentId){
        Integer integer = eduSubjectService.ChangeStatusId(id, statusId,parentId);
        return Result.success();
    }

    @ApiOperation(value = "添加分类")
    @PostMapping("/insertsubject")
    private Result insertSubject(@RequestBody EduSubject eduSubject){
        Integer insertsubject = eduSubjectService.insertsubject(eduSubject);
        return Result.success();
    }

    @ApiOperation(value = "修改分类")
    @PostMapping("/updatesubject")
    private Result updatesubject(@RequestBody EduSubject eduSubject){
        Integer updatesubject = eduSubjectService.updatesubject(eduSubject);
        return Result.success();
    }

    @ApiOperation(value = "删除")
    @PostMapping("/deletesubject/{id}")
    private Result deletesubject(@PathVariable String id){
        Integer deletesubject = eduSubjectService.deletesubject(id);
        return Result.success();
    }

}
